package com.ccsoft.atools.controller;

import com.ccsoft.atools.model.DynamicQueryParams;
import com.ccsoft.atools.utils.DynamicDBUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @ClassName:DynamicDBController
 * @Description:TODO
 * @Author:chanchaw
 * @Date:2019/11/14 13:17
 * @Version:1.0
 **/
@CrossOrigin
@RestController
@RequestMapping("/dynamicDBController")
public class DynamicDBController {
    @Autowired
    private DynamicDBUtils dynamicDBUtils;

    @PostMapping("/queryForList")
    public List<Map<String, Object>> queryForList(@RequestBody DynamicQueryParams dqp) {
        return dynamicDBUtils.queryForList(dqp.getDbConfig(), dqp.getSql());
    }
}
